package com.yl.ydk.ui.activity

import android.view.View
import com.yl.ydk.R
import com.yl.ydk.base.BaseActivity
import com.yl.ydk.bean.body.GoodsDetailBody
import com.yl.ydk.presenter.contract.HealthyGoodsDetailContract
import com.yl.ydk.presenter.impl.HealthyGoodsDetailImpl
import com.blankj.utilcode.utils.ToastUtils
import kotlinx.android.synthetic.main.roob_bar.*

class HealthyGoodsDetailActivity : BaseActivity(), View.OnClickListener,
    HealthyGoodsDetailContract.View {

    private val mPresenter = HealthyGoodsDetailImpl()

    override fun getLayoutId(): Int = R.layout.activity_healthy_goods_detail

    override fun attachView() {
        mPresenter.attachView(this)
    }

    override fun detachView() {
        mPresenter.detachView()
    }

    override fun initView() {

        tvTitle.text = "商品详情"
        rlBack.setOnClickListener(this)
        val googsId = intent.getIntExtra("data", 0)
        val body = GoodsDetailBody(googsId)
        mPresenter.getGoodsDetail(this, body)

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.rlBack -> {
                finish()
            }
        }
    }

    override fun showError(message: String?) {
        ToastUtils.showLongToastSafe(message)
    }

}